package com.hw01.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket api() {
        // http://<host>:<port>/swagger-ui/index.html
        // http://localhost:8282/hw01/swagger-ui/index.html
        return new Docket(DocumentationType.OAS_30) // swagger 版本号
                // .enable(false) // 关闭文档
                .apiInfo(new ApiInfoBuilder().title("接口文档")
                        .description("项目描述...")
                        .version("v1")
                        .contact(new Contact("z", "", ""))
                        .build()
                )
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.hw01.controller")) // 扫描路径
                .paths(PathSelectors.any())
                .build();
    }



}